#include "common_message.h"
#include "common_includes.h"

COM_TASK_DEF(ComMsg);

static void common_user_msg_handler(Task task, MessageId id, Message msg)
{
    UNUSED(task);
	msg = msg;
	
    switch (id)
    {		
 
		default :break; 
    }
}


bool common_user_msg_init(void)
{

	COM_TASK_INIT(ComMsg, common_user_msg_handler);
	
	common_input_message_init();

    return TRUE;
}

void common_message_send(ComMsgType_e type, MessageId id, void *message, uint32 delay)
{
	switch (type)
	{
		case COMMON_MSG_TYPE_USER:
		{
			MessageSendLater(COM_GET_TASK(ComMsg), id, message, delay);
			break;
		}

		case COMMON_MSG_TYPE_BUTTON:
		{
            MessageSendLater(COM_GET_TASK(InputMsg), id, message, delay);
			break;
		}	

		case COMMON_MSG_TYPE_SYSTEM:
		{
            MessageSendLater(sinkGetMainTask(), id, message, delay);
			break;
		}
		
		default:break;
	}
    
}

void common_message_cancel(ComMsgType_e type, MessageId id)
{
	switch (type)
	{
		case COMMON_MSG_TYPE_USER:
		{
			MessageCancelAll(COM_GET_TASK(ComMsg), id);
			break;
		}

		case COMMON_MSG_TYPE_BUTTON:
		{
            MessageCancelAll(COM_GET_TASK(InputMsg), id);
			break;
		}	

		case COMMON_MSG_TYPE_SYSTEM:
		{
            MessageCancelAll(sinkGetMainTask(), id);
			break;
		}		
		default:break;
	}

}

